<template>
  <div class="app-container">
    <div class="table-operation">
      <span>
        <auth-button @click="c" name="新增" />
      </span>
      <el-pagination
        v-bind="elPaginationProps"
        :total="list.total"
        :currentPage.sync="list.filter.pageNo"
        :pageSize.sync="list.filter.pageSize"
      />
    </div>
    <el-table v-loading="list.loading" :data="list.data" v-bind="tableProp">
      <el-table-column label="标签类型" prop="typeName" />
      <el-table-column label="标签">
        <template slot-scope="{ row }">
          <dynamic-tag v-model="row.lable" :disabled="true" />
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="{ row }">
          <auth-button @click="u({ id: row.id })" name="编辑" />
          <auth-button @click="d({ id: row.id })" name="删除" />
        </template>
      </el-table-column>
    </el-table>

    <KiFormDialog
      :show.sync="form.show"
      :title="formTitle"
      v-model="form.data"
      :submit="submitForm"
      :readonly="form.status === 'r'"
      ref="formRef"
      :loading="form.loading"
    >
      <template #el-form>
        <el-form-item label="类型名称" prop="type" verify>
          <KiSelect
            v-model="form.data.type"
            :label.sync="form.data.typeName"
            :options="dict.discover_label_type"
          />
        </el-form-item>
        <el-form-item label="标签" prop="lable" verify>
          <dynamic-tag v-model="form.data.lable" maxlength="7" count="9" />
        </el-form-item>
      </template>
    </KiFormDialog>
  </div>
</template>

<script>
import pageMixin from '@/utils/pageMixin'
import useAdmateAdapter from '@/utils/useAdmateAdapter'
import { DynamicTag } from 'dynamic-tag'

export default {
  mixins: [pageMixin],
  components: { DynamicTag },
  setup: () =>
    useAdmateAdapter({
      urlPrefix: 'one-travel-api/discover-label',
      list: {
        filter: {
          status: null
        }
      }
    })
}
</script>

<style lang="scss" scoped></style>
